programming4us
           
 
 
Programming

iPad SDK : Preparing Dudel for a New Tool (part 2) - Implementing Changes to the Controller Class

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
1/15/2011 4:14:44 PM

3. Implementing Changes to the Controller Class

Let's return to DudelViewController, and make the implementation changes to match the new things in the interface. Open DudelViewController.m, and start off by adding the following near the top of the file, so that the controller will get access to the new TextTool class we'll soon create:

#import "TextTool.h"

We also have the new font property to synthesize. Add it to the existing line:

@synthesize currentTool, fillColor, strokeColor, strokeWidth, font;

Next, we want to make sure we have a default value for the font, so add a line to viewDidLoad, like this:

- (void)viewDidLoad {
[super viewDidLoad];
self.currentTool = [DotTool sharedDotTool];
[dotButton setImage:[UIImage imageNamed:@"button_dot_selected.png"]];
self.fillColor = [UIColor colorWithWhite:0.0 alpha:0.25];
self.strokeColor = [UIColor blackColor];
self.font = [UIFont systemFontOfSize:24.0];
}

Now let's update the deselectAllToolButtons method so that it knows about the new button:

- (void)deselectAllToolButtons {
[textButton setImage:[UIImage imageNamed:@"button_text.png"]];
[freehandButton setImage:[UIImage imageNamed:@"button_bezier.png"]];
[ellipseButton setImage:[UIImage imageNamed:@"button_ellipse.png"]];
[rectangleButton setImage:[UIImage imageNamed:@"button_rectangle.png"]];
[lineButton setImage:[UIImage imageNamed:@"button_line.png"]];
[dotButton setImage:[UIImage imageNamed:@"button_dot.png"]];
}

Finally, implement the method that the new button will call:

- (IBAction)touchTextItem:(id)sender {
self.currentTool = [TextTool sharedTextTool];
[self deselectAllToolButtons];
[textButton setImage:[UIImage imageNamed:@"button_text_selected.png"]];
}


Those are all the changes our controller class needs in order to handle the new tool. Next, let's update the ToolDelegate protocol to match the new bit of functionality in the controller. Our new Text tool will want to get the currently selected font from the controller, which it knows of only as an object conforming to the ToolDelegate protocol. Edit the Tool.h file, and add a line to the ToolDelegate section at the bottom:

@protocol ToolDelegate
- (void)addDrawable:(id <Drawable>)d;
- (UIView *)viewForUseWithTool:(id <Tool>)t;
- (UIColor *)strokeColor;
- (UIColor *)fillColor;
- (UIFont *)font;
@end
Other -----------------
- Coding JavaScript for Mobile Browsers (part 9) - Scripting Styles
- Coding JavaScript for Mobile Browsers (part 8) - DOM
- Coding JavaScript for Mobile Browsers (part 7)
- Coding JavaScript for Mobile Browsers (part 6)
- iPad SDK : The Structure of Core Text
- iPad SDK : PDF Generation
- jQuery 1.3 : Sorting and paging (part 5) - Finessing the sort keys
- jQuery 1.3 : Sorting and paging (part 4)
- jQuery 1.3 : Sorting and paging (part 3) - Using a comparator to sort table rows
- jQuery 1.3 : Sorting and paging (part 2) - JavaScript sorting
- jQuery 1.3 : Sorting and paging (part 1) - Server-side sorting
- Coding JavaScript for Mobile Browsers (part 5)
- Coding JavaScript for Mobile Browsers (part 4)
- Coding JavaScript for Mobile Browsers (part 3) - Writing to the document
- Coding JavaScript for Mobile Browsers (part 1) - Standard dialogs
- Coding JavaScript for Mobile Browsers (part 1) - Code Execution
- Programming the Mobile Web : JavaScript Mobile - Supported Technologies
- Security in Cloud Computing (part 4) - Audit and Compliance
- Security in Cloud Computing (part 3)
- Security in Cloud Computing (part 2) - Identity and Access Management
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us